/*
   Copyright [2013] [szhu1@umbc.edu]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
package szhu.hcc.umbc.crowdsourcing.quality.core;

import java.util.ArrayList;
import java.util.List;

/**
 * The core interface for quality judging library.
 *
 * @author szhu1@umbc.edu
 */
public interface QualityJudgingCore {
    public static final int MAX_WORKER_PER_TASK = 5;
    public static final double LINEAR_REGRESSION_BEST_PERCENT_INTERVAL = 0.01;

    enum RefinementType {
        EMPIRICAL_DECREASING, LINEAR_REGRESSION,
    }

    enum OptimizeType {
        F_VALUE, RECALL, PRECISION, ACCURACY, CUSTOMIZE
    }

    /**
     * Get the model fitness based on optimize type (i.e. Prevision/recall or f meausre).
     * <p/>
     * Todo(shaojian): Add support for more measures.
     */
    double getModelFitness(int[] modelFits, OptimizeType type);

    List<String> getAllUserIds(List<RawData> rawLogs);

    /**
     * The order of params are {constant, coefficient #1, coefficient #2 ....}.
     */
    double[][] getLinearRegressionParams(ArrayList[] taskNatures, ArrayList[] userEfforts);

    /**
     * The core method.
     */
    double[] evaluate(List<Integer> trainingTaskIDs, List<Integer> withinTaskWorkerids, OptimizeType type,
                      String logPrefix, boolean isStrict, double... weights);

    double[] evaluate(OptimizeType optimizeType, RefinementType refinementType, List<Integer> trainingTaskIDs,
                      List<Integer> withinTaskWorkerids, String logPrefix, boolean isStrict);
}
